@namespace SageKing.Studio.Pages.Dashboard.Components 
@inherits StudioComponentBase

@if (WorkflowDefinition != null)
{
    <div>
        <MudText Typo="Typo.overline">Settings</MudText>
        <MudStack Spacing="3">
            <MudSelect
                T="WorkflowActivationStrategyDescriptor"
                Label="Activation strategy"
                Variant="@Variant.Outlined"
                Value="@_selectedActivationStrategy"
                ToStringFunc="@(x => x?.DisplayName ?? string.Empty)"
                ValueChanged="@OnActivationStrategyChanged"
                HelperText="@(_selectedActivationStrategy?.Description)"
                ReadOnly="IsReadOnly" Disabled="IsReadOnly">
                @foreach (var strategy in _activationStrategies)
                {
                    <MudSelectItem T="WorkflowActivationStrategyDescriptor" Value="@strategy">@strategy.DisplayName</MudSelectItem>
                }
            </MudSelect>
            <MudSelect
                T="IncidentStrategyDescriptor"
                Label="Incident handling strategy"
                Variant="@Variant.Outlined"
                Value="@_selectedIncidentStrategy"
                ToStringFunc="@(x => x?.DisplayName ?? "Default")"
                ValueChanged="@OnIncidentStrategyChanged"
                HelperText="@(_selectedIncidentStrategy?.Description)"
                ReadOnly="IsReadOnly" Disabled="IsReadOnly">
                @foreach (var strategy in _incidentStrategies)
                {
                    <MudSelectItem T="IncidentStrategyDescriptor" Value="@strategy">@(strategy?.DisplayName ?? "Default")</MudSelectItem>
                }
            </MudSelect>
            <MudSelect
                Label="Log Persistence Mode"
                T="LogPersistenceMode?"
                Variant="@Variant.Outlined"
                Value="@_selectedLogPersistenceMode"
                ValueChanged="@OnLogPersistenceModeChanged"
                ReadOnly="IsReadOnly" Disabled="IsReadOnly">
                @foreach (LogPersistenceMode item in Enum.GetValues(typeof(LogPersistenceMode)))
                {
                    <MudSelectItem Value="@((LogPersistenceMode?)item)">@item</MudSelectItem>
                }
            </MudSelect>
            <MudField Variant="Variant.Text" HelperText="Allow this workflow to be used as an activity." Margin="Margin.None">
                <MudCheckBox
                    T="bool?"
                    Label="Usable as activity"
                    Value="@(WorkflowDefinition.Options.UsableAsActivity == true)"
                    ValueChanged="@OnUsableAsActivityCheckChanged"
                    Dense="true"
                    ReadOnly="IsReadOnly" Disabled="IsReadOnly"/>
            </MudField>
            @if (WorkflowDefinition.Options.UsableAsActivity == true)
            {
                <MudField Variant="Variant.Text" HelperText="When you publish a new version, all of the consuming workflows will be updated to point to the new version of this workflow." Margin="Margin.None">
                    <MudCheckBox
                        T="bool?"
                        Label="Auto-update consuming workflows"
                        Dense="@true"
                        Value="@(WorkflowDefinition.Options.AutoUpdateConsumingWorkflows)"
                        ValueChanged="@OnAutoUpdateConsumingWorkflowsCheckChanged"
                        ReadOnly="IsReadOnly" Disabled="IsReadOnly"/>
                </MudField>
                @* <MudSelect *@
                @*     T="string" *@
                @*     Label="Resolution Strategy" *@
                @*     Variant="@Variant.Outlined" *@
                @*     HelperText="What should we do when a consuming workflow is published and also has a draft version?" *@
                @*     ReadOnly="IsReadOnly" Disabled="IsReadOnly"> *@
                @*     <MudSelectItem T="string">Update Draft</MudSelectItem> *@
                @*     <MudSelectItem T="string">Update Draft and Publish</MudSelectItem> *@
                @*     <MudSelectItem T="string">Discard Draft and Publish</MudSelectItem> *@
                @* </MudSelect> *@
                <MudTextField
                    T="string"
                    Variant="Variant.Outlined"
                    Label="Category"
                    HelperText="A custom activity category to assign this workflow-as-an-activity to."
                    Value="@WorkflowDefinition.Options.ActivityCategory"
                    ValueChanged="OnCategoryChanged" ReadOnly="IsReadOnly" Disabled="IsReadOnly"/>
            }
        </MudStack>
    </div>
}